import java.util.LinkedList;

import junit.framework.Assert;

import org.junit.Before;
import org.junit.Test;

public class FrameTest
{
	private LinkedList<Frame> frames=new LinkedList<Frame>();
	@Before
	public void SetUp()
	{
		frames.add(new Frame());
		for (int x = 1; x <= 8; x++)
		{
			frames.add(new Frame());
			frames.get(x-1).setNext(frames.get(x));
		}
		frames.add(new TenthFrame());
		frames.get(8).setNext(frames.get(9));
	}
	@Test
	public void ShouldBeScore12()
	{
		frames.get(0).bowl(5);
		frames.get(0).bowl(5);
		frames.get(1).bowl(2);
		frames.get(1).bowl(3);
		Assert.assertEquals(12, frames.get(0).getScore());
	}
	@Test
	public void ShouldBeScore17()
	{
		frames.get(0).bowl(10);
		frames.get(1).bowl(5);
		frames.get(1).bowl(2);
		Assert.assertEquals(17, frames.get(0).getScore());
	}
	@Test
	public void ShouldBeScore23()
	{
		frames.get(0).bowl(10);
		frames.get(1).bowl(10);
		frames.get(2).bowl(3);
		Assert.assertEquals(23, frames.get(0).getScore());
	}
	@Test
	public void ShouldBeScore13()
	{
		frames.get(9).bowl(5);
		frames.get(9).bowl(5);
		frames.get(9).bowl(3);
		Assert.assertEquals(13, frames.get(9).getScore());
	}
	@Test
	public void ShouldBeScore20()
	{
		frames.get(9).bowl(5);
		frames.get(9).bowl(5);
		frames.get(9).bowl(10);
		Assert.assertEquals(20, frames.get(9).getScore());
	}
	@Test
	public void ShouldBeScore23again()
	{
		frames.get(9).bowl(10);
		frames.get(9).bowl(10);
		frames.get(9).bowl(3);
		Assert.assertEquals(23, frames.get(9).getScore());
	}
	@Test
	public void ShouldBeScore30()
	{
		frames.get(9).bowl(10);
		frames.get(9).bowl(10);
		frames.get(9).bowl(10);
		Assert.assertEquals(30, frames.get(9).getScore());
	}
	@Test
	public void ShouldBeScore25()
	{
		frames.get(8).bowl(10);
		frames.get(9).bowl(10);
		frames.get(9).bowl(5);
		frames.get(9).bowl(3);
		Assert.assertEquals(25, frames.get(8).getScore());
	}
}
